import 'package:duqin/models/user_model.dart';

/// 列表模型
class SongList {
  List<SongInfo> list;

  SongList(this.list);

  factory SongList.fromJson(List<dynamic> list) {
    return SongList(
      list.map((item) => SongInfo.fromJson(item)).toList(),
    );
  }
}

class SongInfo {
  late int id;
  int? userId;
  String? coverPictureUrl;
  String? songUrl;
  String? cnName;
  String? enName;
  int? commentCount;
  int? thumbUpCount;
  int? readCount;
  UserInfo? user;

  SongInfo(
      {required this.id,
      this.userId,
      this.coverPictureUrl,
      this.songUrl,
      this.cnName,
      this.enName,
      this.commentCount,
      this.thumbUpCount,
      this.readCount,
      this.user});

  factory SongInfo.fromJson(dynamic json) {
    return SongInfo(
        id: json['id'],
        userId: json['userId'],
        coverPictureUrl: json['coverPictureUrl'],
        songUrl: json['songUrl'],
        cnName: json['cnName'],
        enName: json['enName'],
        commentCount: json['commentCount'],
        thumbUpCount: json['thumbUpCount'],
        readCount: json['readCount'],
        user:
            json['user'] != null ? new UserInfo.fromJson(json['user']) : null);
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['userId'] = this.userId;
    data['coverPictureUrl'] = this.coverPictureUrl;
    data['songUrl'] = this.songUrl;
    data['cnName'] = this.cnName;
    data['enName'] = this.enName;
    data['commentCount'] = this.commentCount;
    data['thumbUpCount'] = this.thumbUpCount;
    data['readCount'] = this.readCount;
    if (this.user != null) {
      data['user'] = this.user!.toJson();
    }
    return data;
  }
}
